/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cpasl;

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;

/**
 *
 * @author seanm_000
 */
public class AslFrequencyGridPane extends GridPane {
    
    public AslFrequencyGridPane() {
        
        setAlignment(Pos.CENTER);
        setHgap(15);
        setVgap(15);
        
        Label frequencyLabel = new Label("How frequently do you use ASL now?");
        final ToggleGroup frequencyGroup = new ToggleGroup();
        RadioButton neverButton = new RadioButton("Never 0%");
        neverButton.setUserData("A");
        neverButton.setToggleGroup(frequencyGroup);
        neverButton.setSelected(true);
        RadioButton oneButton = new RadioButton("1% -33%");
        oneButton.setUserData("B");
        oneButton.setToggleGroup(frequencyGroup);
        RadioButton thirtyFourButton = new RadioButton("34% -66%");
        thirtyFourButton.setUserData("C");
        thirtyFourButton.setToggleGroup(frequencyGroup);
        final TextField otherTextField = new TextField();
        RadioButton sixtySevenButton = new RadioButton("67% - 100%");
        sixtySevenButton.setUserData("D");
        sixtySevenButton.setToggleGroup(frequencyGroup);
        
        Button nextButton = new Button();
        nextButton.setText("Submit");
        nextButton.setId("submit-button");
        nextButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent event) {
                String userData = (String) ((RadioButton) frequencyGroup.getSelectedToggle()).getUserData();
                CpaslManager.getInstance().setFrequencyOfAslUse(userData);
                CpaslManager.getInstance().switchToDisplay(Groups.THANK_YOU, 0);
            }
        });
        
        add(frequencyLabel, 0, 0);
        add(neverButton, 0, 1);
        add(oneButton, 0, 2);
        add(thirtyFourButton, 0, 3);
        add(sixtySevenButton, 0, 4);
        add(nextButton, 0, 5);
    }
    
}
